package com.wzh.springbootinit.service.impl.inner;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wzh.apiCommon.model.entity.InterfaceInfo;
import com.wzh.apiCommon.service.InnerInterfaceInfoService;
import com.wzh.springbootinit.common.ErrorCode;
import com.wzh.springbootinit.exception.BusinessException;
import com.wzh.springbootinit.mapper.InterfaceInfoMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @Author wzh
 * @create 2023/4/15 13:46
 * @Description:
 */
@DubboService
public class InnerInterfaceInfoServiceImpl implements InnerInterfaceInfoService {

         @Resource
        private InterfaceInfoMapper interfaceInfoMapper;

    /**
     * 根据路径和方法方式获取接口
     * @param url
     * @param method
     * @return
     */
    @Override
    public InterfaceInfo getInterfaceInfo(String url, String method) {
        if (StringUtils.isAnyBlank(url, method)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        QueryWrapper<InterfaceInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("url", url);
        queryWrapper.eq("method", method);
        return interfaceInfoMapper.selectOne(queryWrapper);
    }
    }

